package com.haredot.mapper;

import com.haredot.dto.PermissionTree;
import com.haredot.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface RoleMapper {

    List<Role> findDefaultRoles();

    int batchSaveRoleAndUser(@Param("userId") Long id, @Param("roles") List<Role> roles);

    Role findRoleByName(String name);

    Role findRoleByRemark(String remark);

    int insert(Role role);

    int update(Role role);

    int deleteById(Long id);

    int batchDeleteByIds(List<Long> roleIds);

    List<Role> findRolesByCondition(Map<String, Object> searchParams);

    List<PermissionTree> findTreeRefRoleId(Long roleId) ;

    int removePermissionByRoleId(Long roleId);

    int batchSavePermission(@Param("roleId") Long roleId, @Param("nodes") List<PermissionTree> nodes);
}